import { request } from '../request';

/** get role list */
export function fetchGetRoleList(params?: Api.SystemManage.RoleSearchParams) {
  return request<Api.SystemManage.RoleList>({
    url: '/systemManage/getRoleList',
    method: 'get',
    params
  });
}

/**
 * get all roles
 *
 * these roles are all enabled
 */
export function fetchGetAllRoles() {
  // return request<Api.SystemManage.AllRole[]>({
  //   url: '/systemManage/getAllRoles',
  //   method: 'get'
  // });
  return request<Api.SystemManage.AllRole[]>({
    url: '/my/cate/list',
    method: 'get'
  });
}
export interface Role {
  id: string;
  cate_name: string;
  // 其他字段...
}

export function fetchGetAllRoles1(params: Record<string, any>) {
  // 创建 URLSearchParams 对象
  // const urlParams = new URLSearchParams();
  // // 将 params 对象中的所有键值对添加到 URLSearchParams 对象中
  // Object.keys(params).forEach(key => {
  //   urlParams.append(key, params[key]);
  // });

  return request<Api.SystemManage.AllRole[]>({
    url: '/my/article/add',
    method: 'POST',
    data: params,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
}
/** get user list */
export function fetchGetUserList(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.SystemManage.UserList>({
    url: '/systemManage/getUserList',
    method: 'get',
    params
  });
}

// export function fetchGetUserListDemo(params?: Api.SystemManage.UserSearchParams) {
//   return request<Api.SystemManage.UserList>({
//     url: '/my/article/list',
//     method: 'get',
//     params
//   });
// }

export function fetchGetUserListDemo(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.SystemManage.UserList>({
    url: '/my/article/list',
    method: 'get',
    params
  });
}

/** get menu list */
export function fetchGetMenuList() {
  return request<Api.SystemManage.MenuList>({
    url: '/systemManage/getMenuList/v2',
    method: 'get'
  });
}

/** get all pages */
export function fetchGetAllPages() {
  return request<string[]>({
    url: '/systemManage/getAllPages',
    method: 'get'
  });
}

/** get menu tree */
export function fetchGetMenuTree() {
  return request<Api.SystemManage.MenuTree[]>({
    url: '/systemManage/getMenuTree',
    method: 'get'
  });
}
